package com.frx.leetoffer.dayone;

/**
 * @author ：frx
 * @date ：Created in 2019/11/17 22:04
 * @description：ToDO
 * @modified By：
 * @version: ToDO
 */
public class FindRotateMin {

    public static void main(String[] args){
        int[] arr = {5,6,7,8,2,3,4};
        System.out.println(solution(arr));
    }
    public static int solution(int[] array){
        if (array.length == 0){
            return 0;
        }
        int left = 0;
        int right = array.length-1;
        while (left < right){
            int mid = (left + right)/2;
            if (array[mid] >= array[right]){
                left = mid + 1;
            } else {
                right = mid;
            }
        }

        return array[left];
    }
}
